<template>
  <div>
    <h1>设置</h1>
    <input 
      v-model="intervalTime" 
      type="number" 
      placeholder="Enter Interval Time" 
      class="custom-input"
    />
    <button @click="saveIntervalTime" class="custom-button">Save config</button>
  </div>
</template>

<script>
import fs from 'fs';
import path from 'path';

export default {
  name: 'Page4',
  data() {
    return {
      intervalTime: null
    };
  },
  methods: {
    saveIntervalTime() {
      if (this.intervalTime && !isNaN(this.intervalTime)) {
        const configPath = path.resolve(__dirname, '../../config/config.json');
        const configData = JSON.parse(fs.readFileSync(configPath, 'utf8'));
        configData.IntervalTime = this.intervalTime;
        fs.writeFileSync(configPath, JSON.stringify(configData, null, 2), 'utf8');
        this.intervalTime = null;
      } else {
        console.log('Invalid Interval Time');
      }
    }
  }
};
</script>